﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameEngine.EntityComponents;
using GameEngine.Entities;
using PvT.Entities;

namespace PvT.EntityComponent
{
    public class LazerComponent : IEntityComponent
    {
        private AbstractEntity entity;

        /// <summary>
        /// Initializes a new instance of the <see cref="LazerComponent" /> class.
        /// </summary>
        /// <param name="entity">The entity.</param>
        public LazerComponent(AbstractEntity entity)
        {
            this.entity = entity;
        }

        public void Update(Microsoft.Xna.Framework.GameTime gameTime)
        { }

        /// <summary>
        /// This method decides what to do if a collision occurs with this component
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="isX">if set to <c>true</c> [is X].</param>
        /// <param name="isY">if set to <c>true</c> [is Y].</param>
        public void CollideWith(GameEngine.Entities.AbstractEntity target, bool isX, bool isY)
        {
            if (target is PlayerEntity)
            {
                if (!((PlayerEntity)(target)).PlasmaImmune)
                {
                    TerminateableComponent terminateable = (TerminateableComponent)target.GetComponent(typeof(TerminateableComponent));
                    if (terminateable != null)
                        terminateable.DealDamage(10f);
                }
            }
        }
    }
}
